﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class FicheJoueurs : System.Web.UI.Page
{
    
    
    protected void Page_Load(object sender, EventArgs e)
    {

        if (Page.IsPostBack == false)
        {

            int id;

            id = Convert.ToInt32(Request.Params["id"]);
            //Recuperation des infos du joueur

            Adherent EntiteAdherent = AdherentDAO.retournerUnAdherent(id);
            lbId.Text = Convert.ToString(EntiteAdherent.id);
            tbNom.Text = EntiteAdherent.nom;
            tbPrenom.Text = EntiteAdherent.prenom;
            tbNaissance.Text = EntiteAdherent.dateDesinscription.ToShortDateString();
            tbAdresse.Text = EntiteAdherent.adresse;
            tbCp.Text = EntiteAdherent.cp;
            tbVille.Text = EntiteAdherent.ville;
            tbTel.Text = EntiteAdherent.tel;
            tbNaissance.Text = EntiteAdherent.dateNaissance.ToShortDateString();
            tbMail.Text = EntiteAdherent.mail;

            Joueur EntiteJoueur = JoueurDAO.retournerUnJoueur(id);
            imagejoueur.ImageUrl = "~/Images/" + EntiteAdherent.lienPhoto;
            tbPoste.Text = EntiteJoueur.poste.ToString();
            tbPied.Text = EntiteJoueur.piedJoueur;
            tbPoidsAdherent.Text = EntiteJoueur.poids.ToString();
            tbTailleAdherent.Text = EntiteJoueur.taille.ToString();
            tbClubAdherent.Text = EntiteJoueur.ancienClub;

            tbNom.Enabled = false;
            tbPrenom.Enabled = false;
            tbNaissance.Enabled = false;
            tbAdresse.Enabled = false;
            tbCp.Enabled = false;
            tbVille.Enabled = false;
            tbTel.Enabled = false;
            tbNaissance.Enabled = false;
            tbMail.Enabled = false;

            tbPoste.Enabled = false;
            tbPied.Enabled = false;
            tbPoidsAdherent.Enabled = false;
            tbTailleAdherent.Enabled = false;
            tbClubAdherent.Enabled = false;

            Btnvalider.Visible = false;
        }

    }
    protected void Btnmodifier_Click(object sender, EventArgs e)
    {
        Btnmodifier.Visible = false;
        Btnvalider.Visible = true;

        tbAdresse.Enabled = true;
        tbCp.Enabled = true;
        tbVille.Enabled = true;
        tbTel.Enabled = true;
        tbMail.Enabled = true;


    }
    protected void Btnvalider_Click(object sender, EventArgs e)
    {
        AdherentCritere unAdherentcritere = new AdherentCritere();


        unAdherentcritere.id = Convert.ToInt32(lbId.Text) ;
        unAdherentcritere.adresse = tbAdresse.Text;
        unAdherentcritere.cp = tbCp.Text;
        unAdherentcritere.ville = tbVille.Text;
        unAdherentcritere.tel = tbTel.Text;
        unAdherentcritere.mail = tbMail.Text;

       
        Adherent EntiteAdherent = AdherentDAO.modifierAdherent(unAdherentcritere);

        Btnmodifier.Visible = true;
        Btnvalider.Visible = false;

        tbAdresse.Enabled = false;
        tbCp.Enabled = false;
        tbVille.Enabled = false;
        tbTel.Enabled = false;
        tbMail.Enabled = false;




    }
}
